// xmlTool.js
const xml2js = require('xml2js')

exports.xmlToJson = (str) => {
  return new Promise((resolve, reject) => {
    const parseString = xml2js.parseString
    parseString(str,{explicitArray : false} ,(err, result) => {
      if (err) {
        reject(err)
      } else {
        resolve(result.xml)
      }
    })
  })
};

exports.jsonToXml = (obj) => {
  const builder = new xml2js.Builder()
  return builder.buildObject(obj)
};



